import {
	mapGetters
} from 'vuex'
export default {

	computed: {
		...mapGetters('m_cart', ['checkedCount', 'total'])
	},

	methods: {
		setBadge() {
			if (this.checkedCount == 0) {
				uni.removeTabBarBadge({
					index: 2,
					text: ''
				})
			} else {
				uni.setTabBarBadge({
					index: 2,
					text: this.checkedCount + ''
				})
			}
		}
	},
	watch: {
		checkedCount: {
			handler(newVal) {
				this.setBadge()
			},
			immediate: true
		}
	},

	onShow() {
		this.setBadge()
	}
}
